<!--
 * @Description: 富文本页面
 * @Author: ZhangHan
 * @Date: 2025-08-08 14:39:14
 * @LastEditTime: 2025-08-08 15:02:55
 * @LastEditors: ZhangHan
-->
<template>
  <view>
    <rich-text :nodes="content" />
  </view>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { PreviewData } from "@/utils/previewData";

const content = ref();
const pData = PreviewData.getInstance();
onLoad(() => {
  const data = pData.getData();
  content.value = data
    .replace(/<img[^>]*>/gi, function (match) {
      return match.replace(
        /style\s*?=\s*?([‘"])[\s\S]*?\1/gi,
        'style="max-width:100%;height:auto;"'
      );
    })
    .replace(/&nbsp;/g, "\xa0")
    .replace(/&amp;/g, "&");
});
</script>
